package leetcode.code1808;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	int mod = (int) 1e9 + 7;

	public int maxNiceDivisors(int primeFactors) {
		int n = primeFactors / 3;
		if (n == 0)
			return primeFactors;
		int m = primeFactors % 3;
		if (m == 0) {
			return (int) pow(3, n);
		} else if (m == 2) {
			return (int) (pow(3, n) * 2 % mod);
		}
		return (int) (pow(3, n - 1) * 2 * 2 % mod);
	}

	private long pow(int i, int n) {
		if (n == 0) {
			return 1;
		}
		long ans = pow(i, n >> 1);
		if ((n & 1) == 0) {
			return ans * ans % mod;
		}
		return ans * ans * i % mod;
	}
	

	@Override
	public void debug4() {
		H.compare(530358279, this.maxNiceDivisors(71451211));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		System.out.println(296307974 * 296307974);
	}

}
